<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>下载状态监控</title>
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<meta http-equiv="content-type" content="text/html; charset=UTF-8">
		<link rel="stylesheet" type="text/css" href="resources/jquery-easyui-1.5.3/themes/default/easyui.css">
		<link rel="stylesheet" type="text/css" href="resources/jquery-easyui-1.5.3/themes/icon.css">
		<script type="text/javascript" src="resources/jquery-easyui-1.5.3/jquery.min.js"></script>
		<script type="text/javascript" src="resources/jquery-easyui-1.5.3/jquery.easyui.min.js"></script>

	</head>
	<body>

		<table id="manager"></table>

		<div id="manager_tool" style="padding:5px;">
			<div style="margin-bottom:5px;">
				<a href="#" class="easyui-linkbutton" iconCls="icon-search" style="top:3px;" onclick="manager_tool.search();">查询</a>
				<input type="text" id='province_name' class="textbox" name="province_name" style="width:200px;margin-left: 5px;">
				<select name="download_status" id="download_status" style='width:205px;' class="textbox easyui-combobox">
							<option value="">请选择状态</option>
							<option value="1">正常</option>
							<option value="-1">异常</option>			
				</select> 
			</div>
		</div>
		<script>
			$(function () {
				$('#manager').datagrid({
					url : 'http://gyp.meidongya.cn/ProgramInfo/control/',
					fit : true,
					fitColumns : true,
					striped : true,
					rownumbers : true,
					border : false,
					pagination : true,
					nowrap:false,
					pageSize : 25,
					pageNumber : 1,
					pageList : [25, 50, 75,],
					toolbar : '#manager_tool',
					columns : [[
						{
							field : 'ck',
							width : 10,
							checkbox : true,
						},
						{
							field : 'id',
							title : '序号',
							width : 20,
						},
						{
							field : 'taskid',
							title : '任务号',
							width : 20,
						},
						{
							field : 'province',
							title : '省份',
							width : 20,
						},
						{
							field : 'username',
							title : '用户名',
							width : 20,
						},
						{
							field : 'ip',
							title : 'ip地址',
							width : 20,
						},
						{
							field : 'version',
							title : '版本号',
							width : 30,
						},
						{
							field : 'status',
							title : '状态',
							width : 20,
							styler: function(value,row,index){
								if (row.status==1){    
					            return 'color:#448BCD;';    
					        	} 
					        	if (row.status==-1){    
					            return 'color:red;';    
				        		}
				        	},
							formatter: function(value,row,index){
								if(value==1){
									return '正常';
								} else if(value==-1){
									return '异常';
								} else{
									return "未知";
								}
							},
						},
						{
							field : 'create_time',
							title : '创建时间',
							width : 30,
							formatter: function(value,row,index){
								var date = new Date();
								date.setTime(value * 1000);  
							    var y = date.getFullYear();      
							    var m = date.getMonth() + 1;      
							    m = m < 10 ? ('0' + m) : m;      
							    var d = date.getDate();      
							    d = d < 10 ? ('0' + d) : d;      
							    var h = date.getHours();    
							    h = h < 10 ? ('0' + h) : h;    
							    var minute = date.getMinutes();    
							    var second = date.getSeconds();    
							    minute = minute < 10 ? ('0' + minute) : minute;      
							    second = second < 10 ? ('0' + second) : second;     
							    return y + '-' + m + '-' + d+' '+h+':'+minute+':'+second; 
							},
						},
						{
							field : 'update_time',
							title : '更新时间',
							width : 30,
							formatter: function(value,row,index){
								var date = new Date();
								date.setTime(value * 1000);  
							    var y = date.getFullYear();      
							    var m = date.getMonth() + 1;      
							    m = m < 10 ? ('0' + m) : m;      
							    var d = date.getDate();      
							    d = d < 10 ? ('0' + d) : d;      
							    var h = date.getHours();    
							    h = h < 10 ? ('0' + h) : h;    
							    var minute = date.getMinutes();    
							    var second = date.getSeconds();    
							    minute = minute < 10 ? ('0' + minute) : minute;      
							    second = second < 10 ? ('0' + second) : second;     
							    return y + '-' + m + '-' + d+' '+h+':'+minute+':'+second; 
							},
						},
					]], 
				});

				setInterval(function(){
					$('#manager').datagrid('reload')
				},30000);

				$('#province_name').combotree({
					url : 'http://gyp.meidongya.cn/SysUser/get_canuse_province',
					lines : true,
					/*multiple : false,*/
					/*checkbox : true,*/
					editable: true,
					onlyLeafCheck : true,
					onLoadSuccess : function (node, data) {
						//console.log(data);
						var _this = this;
						if (data) {
							$(data).each(function (index, value) {
								//console.log(value)
								if (this.state == 'closed') {
									$(_this).tree('expandAll');
								}
							});
						}
					},
				});

				manager_tool = {
					search:function(){
						$('#manager').datagrid('load', {
							province_name : $.trim($('#province_name').combotree('getText')),
							status: $('input[name="download_status"]').val(),
						});
					}
				};	
			});

		</script>
	</body>
</html>
